package com.osdp.sc.mapper;

import com.osdp.sc.entity.ScRole;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * <p>
 * 角色表 Mapper 接口
 * </p>
 *
 */
@Repository
public interface ScRoleMapper extends BaseMapper<ScRole> {

    /**
     * 通过用户ID查询角色信息列表
     * @param userId String
     * @return List<RoleVO>
     */
    @Select({"<script>",
            "select * from sc_role r left join sc_role_user ur on r.id = ur.role_id where ur.user_id = #{userId} ",
            "</script>"})
    List<ScRole> queryRolesByUserId(@Param("userId") String userId);

    /**
     * 通过岗位ID查询角色信息列表
     * @param positionId String
     * @return List<ScRole>
     */
    @Select({"<script>",
            "select * from sc_role r left join sc_role_position pr on r.id = pr.role_id where pr.position_id = #{positionId} ",
            "</script>"})
    List<ScRole> queryRolesByPositionId(@Param("positionId") String positionId);
}
